﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace SnelsteRoute
{
    internal class ConfigHelper
    {
        internal const String ConfigMaxNrOfSquares = "maxNrOfSquares";
        internal const String ConfigDisplayLimit = "displayLimit";
        internal const String ConfigFinishedRouteCutOff = "finishedRouteCutOff";

        public static String GetString(String key, String defaultValue)
        {
            var value = ConfigurationManager.AppSettings[key];

            if (String.IsNullOrEmpty(value))
                return defaultValue;
            else
            {
                return value;
            }
        }

        public static Int32 GetInt32(String key, Int32 defaultValue)
        {
            var value = ConfigurationManager.AppSettings[key];
            var valueInt = 0;

            if (string.IsNullOrEmpty(value) || !Int32.TryParse(value,out valueInt))
                return defaultValue;
            else
            {
                return valueInt;
            }
        }
    }
}
